home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7775 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.5 KB  |  48 lines

  1. Path: freenet.vancouver.bc.ca!zipz
  2. From: zipz@opus.freenet.vancouver.bc.ca (Patrick Wong)
  3. Newsgroups: comp.lang.c
  4. Subject: argc/argv & switches
  5. Date: 28 Feb 1996 21:59:47 GMT
  6. Organization: Vancouver Regional FreeNet
  7. Message-ID: <4h2j8j$9gn@milo.freenet.vancouver.bc.ca>
  8. NNTP-Posting-Host: opus.freenet.vancouver.bc.ca
  9. X-Newsreader: TIN [version 1.2 PL2]
  10.  
  11. I would like to know the difference between *++argv[0] and (*++argv)[0].
  12. Also, I've seen a lot of programs that have command-line switches like:
  13.  
  14. view -r -x list.txt
  15. view -rx list.txt
  16. view -xr list.txt
  17.  
  18. How can I write the view program so that it can accept all three formats?
  19. It has something to do with the *argv[0] parameter, I know that much.  I
  20. looked at K&R and found the example program confusing (find -n -l pattern).
  21.  
  22. The view program would look like this:
  23. /* begin program */
  24. #include <stdio.h>
  25. main()
  26. {
  27.     int c;
  28.     while ((c = getchar()) != EOF)
  29.       putchar(c);
  30. } /* ok, so it's a simple program... */
  31. /* end program */
  32.  
  33. How can this program be modified to use -r and -x?
  34. -x : pause after a screenful of text.  If less than screnful, ignore
  35. -r : put line numbers in front of each line of text.
  36.  
  37. This program is just something that will help me understand how the
  38. *argv[0] thing works.  Thanks.
  39.  
  40. Patrick
  41.  
  42. --
  43.  
  44. /* Name : Patrick Wong                   : "You can't legislate public   */
  45. /* E-mail : zipz@freenet.vancouver.bc.ca :  opinion; but somehow, the    */
  46. /* Occupation : Student/Programmer       :  government seems to get away */
  47. /* School : BCIT - Computer Systems      :  with it!"                    */
  48.